//
// Created on 2024/10/24.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#ifndef SUB_UNSUB_JSOBSERVER_H
#define SUB_UNSUB_JSOBSERVER_H
#include <memory>
#include "napi/native_api.h"
#include "uv_queue.h"
class JSObserver : public std::enable_shared_from_this<JSObserver> {
public:
    JSObserver(std::shared_ptr<UvQueue> uvQueue, napi_value callback);
    virtual ~JSObserver();
    napi_ref GetCallback();
    void Clear();
    void AsyncCall(UvQueue::NapiArgsGenerator genArgs = UvQueue::NapiArgsGenerator());

private:
    std::shared_ptr<UvQueue> uvQueue_;
    napi_ref callback_;
};

#endif //SUB_UNSUB_JSOBSERVER_H
